<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false"
		 :customBack="back" :is-fixed="true" :title="'设备详情'"></u-navbar>
		<u-cell-group v-model="equipmentInfo" class="wrap">
			<u-cell-item :border-bottom="true" title="设备名称:" :value="equipmentInfo.name" :arrow="false"></u-cell-item>
			<u-cell-item :border-bottom="true" title="所属主体:" :value="equipmentInfo.buildName " :arrow="false"></u-cell-item>
			<u-cell-item :border-bottom="true" title="所在位置:" :value="equipmentInfo.address" :arrow="false"></u-cell-item>
			<u-cell-item :border-bottom="true" title="所属区域:" :value="equipmentInfo.regionName" :arrow="false"></u-cell-item>
			<u-button @click="endTheAlarm" type="primary" shape="square" size="medium" style="width: 49%;">结束误报</u-button>
			<u-button @click="generateWorkOrder" type="primary" shape="square" size="medium" style="width: 49%; float: right;">生成工单</u-button>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				equipmentInfo: {
				
				},
				equipmentId: '',
				alarmInfoId: '',
              
			}
		},
		onLoad(e) {
			console.log(e.ucId)
			this.equipmentId = e.ucId
			this.alarmInfoId = e.alarmInfoId
		},
		onShow(){
			// this.initView(this.equipmentId)
			this.getInequipmentInfo(this.equipmentId)
		},
		methods: {
			back(){
				window.native.back()
			},
			initView() {
				this.pageNum = 0
			},
			generateWorkOrder(){
				this.utils.request("/api/app/fireAlarmInfo/updateInFireAlarmInfo", {
					ucId: this.alarmInfoId,
					feedtype: 1,
					feedback: "设备故障"
				}, "post", "app", true).then(res => {
					uni.navigateTo({
						url:"/pages/index/equipment/callThePolice/edit?ucId="+this.equipmentInfo.ucId
					})
				}).catch(error => {
					console.log(error)
				})
				
			},
			endTheAlarm(){
				window.native.h5Camera()
				window.native.getUri(res=>{
					this.utils.request("/api/app/fireAlarmInfo/updateInFireAlarmInfo", {
						ucId: this.alarmInfoId,
						feedtype: 0,
						feedback: "设备误报",
						fileUrl:res.uri
					}, "post", "app", true).then(res => {
						uni.navigateTo({
							url: '/pages/index/alarm/list',
						});
					}).catch(error => {
						console.log(error)
					})
				})
			},
			getInequipmentInfo(val) {
				this.utils.request("/api/app/equipment/getInEquipmentVo", {	ucId: val}, "post", "app", true).then(res => {
					console.log(res)
					this.equipmentInfo = res.data
					console.log(res.data)
				}).catch(error => {
					console.log(error)
				})
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.list-item {
		padding: 20rpx 40rpx;
		background-color: #fff;
		border-bottom: #999999 1px dashed ;
	
		.list-bottom {
			display: flex;
			margin-top: 10rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #333;
		}
		.list-center {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999999;
		}
		.list-img{
			display: flex;
			margin-top: 10rpx;
			font-size: 28rpx;
			color: #333;
			.text{
				flex: 1;
			}
			.img{
				flex: 3;
			}
		}
	}
</style>
